package com.cmwa.scbp.business.customerEquity.controller;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cmwa.scbp.business.customerEquity.estimate.service.EstimateInfoService;
import com.cmwa.scbp.business.infodisclosure.regulatoryreport.service.RegulatoryReportService;
import com.cmwa.scbp.base.mvc.controller.BaseController;
import com.cmwa.scbp.sys.dictionary.entity.DictionaryVo;
import com.cmwa.scbp.utils.TimeUtil;
import com.cmwa.scbp.utils.cached.DictionaryCached;

@Controller
@RequestMapping("/business/customerEquity")
public class customerEquityControlle extends BaseController{
	private final static String JSP_PATH = "business/customerEquity/estimate/";
	private final static String PAGE_PACKAGE_PATH_NEW = "business/customerEquity/prdFeeYield/";
	@Resource
	private RegulatoryReportService regulatoryReportService;
	@Resource 
	private EstimateInfoService estimateInfoService;
	
	@RequestMapping("/home")
	public String home() {
		return "business/customerEquity/home";
	}
	
	@RequestMapping("/customerEquityList")
	public String infoDisclosureList() {
		return "business/customerEquity/customerEquityList";
	}
	
	@RequestMapping("/countReportData")
	@ResponseBody
	public List<Map<String, String>> countReportData(@RequestParam("reprotDateBgn") String reprotDateBgn,@RequestParam("reprotDateEnd") String reprotDateEnd) {
		return estimateInfoService.countReportData(reprotDateBgn,reprotDateEnd);
	}
	
	/**
	 * 产品费用与收益列表
	 * @author ex-zhengys
	 * @date 2019-01-23 13:34:46
	 * @param model
	 * @return
	 */
	@RequestMapping("/prdFeeYieldListForCustomerEquity")	
    public String prdFeeYieldListForCustomerEquity(@RequestParam("feeType")String feeType,
    		@RequestParam("dateType")String dateType,
    		@RequestParam("type")String type,ModelMap model){
	    String time=TimeUtil.getTime(type);
		String[] times=time.split(",");
		String str = "";
		str += "{";
		str += "'beginDate':'" + times[1] + "',";
		str += "'endDate':'" + times[0] + "',";
		str += "'feeType':'" + feeType+ "',";
		str += "'dateType':'" + dateType + "'";
		str +="}";
	  model.addAttribute("parameter", str);
      return PAGE_PACKAGE_PATH_NEW + "prdFeeYieldList";
	}
	
	/**
	 * 跳转到估值表列表页面
	 * @author ex-zhengqq
	 * @date 2019-01-23 13:34:46
	 * @param model
	 * @return
	 */
	@RequestMapping("/estimateInfoListView")
	public String estimateInfoListView(@RequestParam("isEstimate") String isEstimate,@RequestParam("type") String type,@RequestParam("reportFrequency") String reportFrequency,ModelMap model) {
		String parameter = "{'isEstimate':'"+isEstimate+"','reportFrequency':'"+reportFrequency+"','type':'"+type+"'}";
		List<DictionaryVo> dicList = DictionaryCached.getDictionaryByRootType("TODO_STATUS");
		model.addAttribute("dicList",dicList);
		model.addAttribute("parameter", parameter);
		return JSP_PATH + "estimateList";
	}
}
